<!DOCTYPE html>
<html>
<div th:replace="common/jsCssRef :: jsfJsCssRef"></div>
<body class="bgf6">

	<div th:replace="common/head :: jsfHeader"></div>
	
	<div class="main-body pb100">
		<div class="container pt10">
			<div class="dflx sbt" id="app">
				<div th:replace="common/left :: jsfLeft"></div>
				
				<div class="body-right">
					<div class="bread-nav bgff">
						<ul class="dflx">
							<li><a href="">首页</a></li>
							<li><a href="">统筹规划</a></li>
							<li><a href="/view/developPlan">全市发展规划</a></li>
							<li><a href="###">编辑</a></li>
						</ul>
					</div>
					
					<div class="bgff mt10 pb20 edit-mode">
						<div class="wrap">

                            <div class="box">
                            	<div class="box-title"><span>编制规划基本信息</span></div>
                            	<div class="mt20 f14">
                            		<div class="two">
                            			<span class="title"><i class="cred">*</i> 规划名称</span>
	                					<div class="content">
	                						<input type="text" id="planName" class="form-control" v-model="plan.planName" placeholder="请输入规划名称"/>
	                					</div>
	                        			<span class="title">规划编号</span>
	                					<div class="content">
	                						<input type="text" id="planNo" class="form-control" v-model="plan.planNo" placeholder="请输入规划编号"/>
                						</div>
                            		</div>
                            		<div class="two">
                            			<span class="title">开始年份</span>
	                					<div class="content">
	                						<div class="input-group">
												<input type="text" id="planBeginTime" class="form-control" v-model="plan.planBeginTime" placeholder="请选择年份">
											</div>
	                					</div>
	                					<span class="title">截止年份</span>
	                					<div class="content">
	                						<div class="input-group">
												<input type="text" id="planEndTime" class="form-control" v-model="plan.planEndTime" placeholder="请选择年份">
											</div>
	                					</div>
                            		</div>
                					<div class="two">
                						<span class="title">编制单位</span>
	                					<div class="content">
	                						<input type="text" id="compileUnit" class="form-control" v-model="plan.compileUnit" placeholder="请输入编制单位"/>
	                					</div>
	                					<span class="title">编制人</span>
	                    				<div class="content"><input type="text" id="compilePerson" v-model="plan.compilePerson" class="form-control" placeholder="请输入编制人" /></div>
                					</div>


                					<div class="two">
                            			<span class="title">编制时间</span>
	                					<div class="content">
	                						<div class="input-group">
												<input type="text" id="compileTime" class="form-control" v-model="plan.compileTime" placeholder="请选择编制时间">
											</div>
	                					</div>
                            		</div>

                            		<div class="one">
                						<span class="title">上传附件</span>
                        				<div class="content">
                        					<input type="file" class="filestyle" data-input="false" id="filestyle-1" tabindex="-1" style="position: absolute; clip: rect(0px, 0px, 0px, 0px);">
                        					<div class="bootstrap-filestyle input-group">
                        						<span class="group-span-filestyle" tabindex="0">
                        							<label for="filestyle-1" class="btn btn-white ">
                        							<span class="icon-cloud-upload"></span>
                        							<span class="buttonText">选择上传文件</span></label>
                        						</span>
                        					</div>
                        					<p class="f12 c999 mt3">只能上传jpg/png/word/pdf/zip/excle/ppt格式文件，文件不能超过50MB</p>
                        				</div>
                					</div>

                					<div class="one">
                						<span class="title">备注</span>
                        				<div class="content">
                        					<textarea name="" id="remark" v-model="plan.remark" class="form-control" placeholder="请输入内容" rows="" cols=""></textarea>
                        				</div>
                					</div>
                            	</div>
                            </div>

                            <div class="box mt30">
                            	<div class="box-title"><span>编制规划审定</span></div>
                            	<div class="mt20 f14">
                            		<div class="two">
                            			<span class="title">审定人</span>
	                					<div class="content">
	                						<input type="text" id="auditPerson" v-model="plan.auditPerson" class="form-control" placeholder="请输入审定人"/>
	                					</div>
	                        			<span class="title">审定时间</span>
	                					<div class="content">
	                						<div class="input-group">
												<input type="text" id="auditTime" v-model="plan.auditTime" class="form-control" placeholder="请选择审定时间">
											</div>
	                					</div>
                					</div>

                            		<div class="two">
                            			<span class="title">审定结果</span>
	                					<div class="content">
	                						<select class="form-control c999" id="auditResult" v-model="plan.auditResult">
												<option value='' disabled selected class='none'>请选择审定结果</option>
												<option value="1">通过</option>
												<option value="2">不通过</option>
		                                    </select>
	                					</div>
                            		</div>

                            		<div class="one">
                						<span class="title">上传附件</span>
                        				<div class="content">
                        					<input type="file" class="filestyle" data-input="false" id="filestyle-2" tabindex="-1" style="position: absolute; clip: rect(0px, 0px, 0px, 0px);">
                        					<div class="bootstrap-filestyle input-group">
                        						<span class="group-span-filestyle" tabindex="0">
                        							<label for="filestyle-1" class="btn btn-white ">
                        							<span class="icon-cloud-upload"></span>
                        							<span class="buttonText">选择上传文件</span></label>
                        						</span>
                        					</div>
                        					<p class="f12 c999 mt3">只能上传jpg/png/word/pdf/zip/excle/ppt格式文件，文件不能超过50MB</p>
                        				</div>
                					</div>

                					<div class="one">
                						<span class="title">审定意见</span>
                        				<div class="content">
                        					<textarea name="" id="auditOpinion" v-model="plan.auditOpinion" class="form-control" placeholder="请输入审定意见（0/200）" rows="" cols=""></textarea>
                        				</div>
                					</div>
                            	</div>
                            </div>

                            <div class="box mt30">
                            	<div class="box-title"><span>编制规划批准</span></div>
                            	<div class="mt20 f14">
                            		<div class="two">
                            			<span class="title">批准人</span>
	                					<div class="content">
	                						<input type="text" id="approvalPerson" v-model="plan.approvalPerson" class="form-control" placeholder="批准人"/>
	                					</div>
	                        			<span class="title">批准时间</span>
	                					<div class="content">
	                						<div class="input-group">
												<input type="text" id="approvalTime" v-model="plan.approvalTime" class="form-control" placeholder="请选择批准时间">
											</div>
	                					</div>
                					</div>

                            		<div class="two">
                            			<span class="title">批准结果</span>
	                					<div class="content">
	                						<select class="form-control c999" id="isApproval" v-model="plan.isApproval">
												<option value='' disabled selected class='none'>请选择批准结果</option>
												<option value="1">通过</option>
												<option value="2">不通过</option>
		                                    </select>
	                					</div>
                            		</div>

                					<div class="one">
                						<span class="title">批准意见</span>
                        				<div class="content">
                        					<textarea name="" id="approvalOpinion" v-model="plan.approvalOpinion" class="form-control" placeholder="请输入批准意见（0/200）" rows="" cols=""></textarea>
                        				</div>
                					</div>
                            	</div>
                            </div>

                            <div class="tc mt40">
                            	<button type="button" class="btn btn-white f12"> 取消 </button>
                            	<button type="button" class="btn btn-primary f12" onclick="submitPlan()"> 提交 </button>
								<button v-if="plan.currentState == 1" type="button" class="btn btn-white f12" onclick="savePlan()"> 保存 </button>
                            </div>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	

<script type="text/javascript">
    $('#planBeginTime').fdatepicker({format: 'yyyy-mm-dd'});
    $('#planEndTime').fdatepicker({format: 'yyyy-mm-dd'});
    $('#compileTime').fdatepicker({format: 'yyyy-mm-dd'});
    $('#auditTime').fdatepicker({format: 'yyyy-mm-dd'});
    $('#approvalTime').fdatepicker({format: 'yyyy-mm-dd'});

    var statusCaoGao = 1;//草稿
    var statusTiJiao = 2;//已提交

	var planId = $.getUrlParam("id");

    var appPage = new Vue({
        el : '#app',
        data : {
            plan : {}
        },
        created : function() {
            loadPlanInfo();
        },
        computed : {

        },
        methods : {
            planStatusDesc : function (val) {
                return statusPlanObj[val];
            }
        }
    })
	
	function submitPlan() {
        processSavePlan(2);
    }

    function savePlan() {
        processSavePlan(1);
    }
    
    function processSavePlan(currentState) {
        var params = {
            'planId' : planId,
            'status' : statusCaoGao,
            'planName' : $('#planName').val(),
            'planNo' : $('#planNo').val(),
            'planBeginTime' : $('#planBeginTime').val(),
            'planEndTime' : $('#planEndTime').val(),
            'compileUnit' : $('#compileUnit').val(),
            'approvalPerson' : $('#approvalPerson').val(),
            'approvalTime' : $('#approvalTime').val(),
            'isApproval' : $('#isApproval').val(),
			'compilePerson' : $('#compilePerson').val(),
			'compileTime' : $('#compileTime').val(),
			'remark' : $('#remark').val(),
			'auditPerson' : $('#auditPerson').val(),
			'auditTime' : $('#auditTime').val(),
			'auditResult' : $('#auditResult').val(),
			'auditOpinion' : $('#auditOpinion').val(),
            'approvalOpinion' : $('#approvalOpinion').val(),
            'planType' : 1,
            'planLocation' : "",  //专项有的字段
            'planLocationCode' : '',
            'compileUnitId' : 0,
            'currentState' : currentState
        }

        $.ajax({
            'url' : contentPath + '/cityPlan/update',
            'dataType' : 'json',
            'type' : 'post',
            'contentType':'application/json',
            'data' : JSON.stringify(params),
            'success' : function (result) {
                if (result.code != 1000) {
                    alert(result.msg);
                    if (result.code == 5555) {
                        window.location.href = contentPath;
                    }
                    return;
                }

                appPage.$message({
                    message: currentState == 1 ? '保存成功' : '提交成功',
                    type: 'success'
                });

                window.location.href = contentPath + '/view/developPlan';
            },
            'error' : function (result) {
            }
        });
    }

	
	function loadPlanInfo() {
        $.ajax({
            'url' : contentPath + '/cityPlan/getOne',
            'dataType' : 'json',
            'type' : 'get',
            'data' : {
                id : planId
            },
            'success' : function (result) {
                if (result.code != 1000) {
                    alert(result.message);
                    return;
                }

                appPage.plan = result.data;
            },
            'error' : function (result) {
            }
        });
    }


</script>
</body>
</html>
